package com.demo.util;

import java.util.Map;

public class SQLParameterTokenHandler implements SimpleTokenHandler {
    private final Map<String, String> params;

    public SQLParameterTokenHandler(Map<String, String> params) {
        this.params = params;
    }

    @Override
    public String handleToken(String content) {
        String ret = null;
        String value = params.get(content);
        if (value != null) {
            ret = value;
        } else {
            throw new IllegalArgumentException("param [" + content + "] not exist");
        }
        return ret;
    }
}
